package com.hibernate.dao.role;


import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.hibernate.entity.Role;

@Repository("roleDAOImp")
public class RoleDAOImp implements IRoleDAO {
	@Autowired
	private HibernateTemplate hibernateTemplate;

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	@Override
	public Serializable save(Role role) {
		return hibernateTemplate.save(role);
	}

	@Override
	public void update(Role role) {
		hibernateTemplate.update(role);
	}

	@Override
	public void delete(Role role) {
		hibernateTemplate.delete(role);
	}

	@Override
	public void get(Role role) {
		hibernateTemplate.get(Role.class, role.getRoleId());
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Role> findAll() {
		return hibernateTemplate.find("from Role");
	}

}
